import {PluginCommand} from "../Command/PluginCommand";

class ControlPointSurfaceCommand extends PluginCommand{
  constructor() {
    super();
  }

  //handle初始化
  handleInit(cb){
    if (this.toolQuery) {
      this.toolQuery.handleInit().then(res => {
        cb(res);
      });
    }
  }
  //预览
  async previewControlPointSurface(params, cb) {
    if (this.toolQuery) {
      let res = await this.toolQuery.executePreviewControlPointSurfaceCmd(params);
      return res?.data?.res;
    }
  }
  //创建
  createControlPointSurface(params, cb){
    if (this.toolQuery) {
      this.toolQuery.executeCreateControlPointSurfaceCmd(params).then(res => {
        cb(res);
      });
    }
  }
  //获取线的点
  async getPointElementByCurveElementId(params, cb){
    if (this.toolQuery) {
      let res = await this.toolQuery.getPointElementByCurveElementId({curveIds: params});
      return res?.data?.pointEle;
    }
  }
  //撤销预览
  async controlPointSurfaceUndoPreview(cb){
    if (this.toolQuery) {
      this.toolQuery.controlPointSurfaceUndoPreview().then(res => {
        cb(res?.data?.res);
      });
    }
  }
  //重做预览
  async controlPointSurfaceRedoPreview(cb){
    if (this.toolQuery) {
      this.toolQuery.controlPointSurfaceRedoPreview().then(res => {
        cb(res?.data?.res);
      });
    }
  }
  //重做预览
  async changeAdjustThreeAxisFlag(params, cb){
    if (this.toolQuery) {
      this.toolQuery.changeAdjustThreeAxisFlag(params).then(res => {
        cb(res);
      });
    }
  }
  //完全恢复
  async controlPointSurfaceFullRestore(cb){
    if (this.toolQuery) {
      this.toolQuery.controlPointSurfaceFullRestore().then(res => {
        cb(res);
      });
    }
  }
  //清空预览
  clearPreViewControlPointSurface(params, cb){
    if (this.toolQuery) {
      this.toolQuery.clearPreViewControlPointSurface();
    }
  }
}

const controlPointSurfaceCommand = new ControlPointSurfaceCommand();
export {controlPointSurfaceCommand};
